package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.TransferHistory;
import cn.wolfcode.crm.mapper.TransferHistoryMapper;
import cn.wolfcode.crm.query.TransferQueryObject;
import cn.wolfcode.crm.service.ITransferHistoryService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransferHistoryServiceImpl implements ITransferHistoryService {
    @Autowired
    private TransferHistoryMapper transferHistoryMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {
        transferHistoryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(TransferHistory entity) {
        transferHistoryMapper.insert(entity);
    }

    @Override
    public TransferHistory selectByPrimaryKey(Long id) {

        return transferHistoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TransferHistory> selectAll() {
        return transferHistoryMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(TransferHistory entity) {
        transferHistoryMapper.updateByPrimaryKey(entity);
    }

    @Override
    public PageResult query(TransferQueryObject qo) {
        Integer total = transferHistoryMapper.query4Count(qo);
        if (total == 0) {
            return PageResult.PAGERESULT_EMPTY;
        }
        List<TransferHistory> histories = transferHistoryMapper.query4List(qo);
        return new PageResult(total, transferHistoryMapper.query4List(qo));
    }
}
